package com.net.wanjian.networkhospitalmanager.activity.dopsminicex;

import android.graphics.Color;
import android.graphics.drawable.PaintDrawable;
import android.os.Bundle;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;

import com.net.wanjian.networkhospitalmanager.R;
import com.net.wanjian.networkhospitalmanager.activity.base.BaseActivity;
import com.net.wanjian.networkhospitalmanager.netstatus.NetUtils;
import com.net.wanjian.networkhospitalmanager.view.LPopupWindow;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by WJ on 2017/8/17.
 */

public class MiniCexScoreActivity extends BaseActivity implements View.OnClickListener {
    @BindView(R.id.img_Mini_Cex_Detail)
    ImageView imgMiniCexDetail;
    @BindView(R.id.rl_top_bar)
    RelativeLayout rlTopBar;
    private LPopupWindow mPopupWindow;

    @Override
    protected void initData() {
        imgMiniCexDetail.setOnClickListener(this);
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_mini_cex_score;
    }

    @Override
    protected void onNetworkConnected(NetUtils.NetType type) {

    }

    @Override
    protected void onNetworkDisConnected() {

    }


    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.img_Mini_Cex_Detail:
                initPopupWindow();
                break;

        }
    }

    private void initPopupWindow() {
        mPopupWindow = new LPopupWindow(this);
        View view = LayoutInflater.from(this).inflate(R.layout.popup_window_min_cex, null);

        //将view添加到popup里面
        mPopupWindow.setContentView(view);
        mPopupWindow.setWidth(WindowManager.LayoutParams.MATCH_PARENT);
        mPopupWindow.setHeight(WindowManager.LayoutParams.WRAP_CONTENT);
        mPopupWindow.setBackgroundDrawable(new PaintDrawable(Color.TRANSPARENT));
        mPopupWindow.setFocusable(true);

        mPopupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
            @Override
            public void onDismiss() {
               // topTitleTagIv.setSelected(false);

                WindowManager.LayoutParams lp = getWindow().getAttributes();
                lp.alpha = 1.0f;
                getWindow().setAttributes(lp);
            }
        });
        //最后显示popupwindow
        if (mPopupWindow.isShowing()) {
            mPopupWindow.dismiss();

        } else {
            //topTitleTagIv.setSelected(true);
            //产生背景变暗效果
            WindowManager.LayoutParams lp = getWindow().getAttributes();
            lp.alpha = 0.8f;
            getWindow().setAttributes(lp);
            mPopupWindow.showAsDropDown(rlTopBar);
        }
    }


}
